<!--
 * @Description:
 * @Author: 
 * @Date: 2023-08-16 09:17:14
 * @LastEditor: 
 * @LastEditTime: 2023-09-01 13:46:00
 
-->


<template>
	<view class="page_content">
		<!-- #ifndef MP-TOUTIAO -->
		<view class="head_content">
			<CustomNavbar :left="0" title="我的"></CustomNavbar>
		</view>
		<!-- #endif -->
		<view class="" style="padding-left: 32rpx; padding-bottom: 50rpx;">
			<u--text text="个人中心" :size="20" color="#ffffff" :bold="true"></u--text>
		</view>
		<view class="main_content" style="background: rgba(235, 236, 237, 1);" v-if="isStatus == 0">
			<view class="userinfo_box" style="flex-direction: column;margin-bottom: 50rpx;" v-if="userInfoStore"
				@click="jumpView('/pages/user/info/index')">
				<view class="avatar" style="margin-bottom: 16rpx;">
					<image class="image" :src="avatar" mode="aspectFill"></image>
				</view>
				<view class="info" style="margin-left:0;display: flex;flex-direction: column;align-items: center;">
					<view class="nickname">
						<text class="text">{{ userInfoStore.nickname }}</text>
						<image class="image" v-if="userInfoStore.is_vip == 1"
							src="https://normalimg.wei.do/video_short/icons/vip.png" mode="widthFix" @click="openVip">
						</image>
					</view>

					<view class="msg" style="display: flex;align-items: center;color: rgba(0, 0, 0, 0.7);">
						<text class="text"
							@click.stop="jumpView('/pages/user/integral/index')">{{ userInfoStore.usable || 0 }}{{richtext.jfname}}</text>
						<view style="margin: 0 20rpx; height: 24rpx;width: 1rpx;background-color: rgba(0, 0, 0, 0.2);">

						</view>
						<text v-if="userInfoStore.is_vip == 1" class="copy" @click.stop="openVip"
							style="color: rgba(0, 0, 0, 0.7);text-decoration: none;">我的会员</text>
						<text v-else class="copy" @click.stop="openVip"
							style="color: rgba(0, 0, 0, 0.7);text-decoration: none;">开通会员</text>
					</view>
				</view>
				<!-- <image class="arrow" src="/static/icons/arrow.png" mode="widthFix"></image> -->
			</view>
			<view class="userinfo_box" style="margin-bottom: 50rpx;flex-direction: column;" v-else
				@click="jumpView('/pages/login/login')">
				<view class="avatar">
					<image class="image" src="https://normalimg.wei.do/video_short/images/avatar.png" mode="aspectFill">
					</image>
				</view>
				<view class="info" style="margin-left: 0;">
					<view class="nickname">
						<text class="text">点我登录11</text>
					</view>
					<view class="msg"></view>
				</view>
			</view>

			<view class="card_box" style="background: none;">
				<view class="item" v-for="(item, index) in cardListTwo" :key="item.id" @click="cardItemClick(item)">
					<!-- <view class="icon" style="margin-bottom: 32rpx;">
						<image class="image" :src="item.img" mode="aspectFill"></image>
					</view> -->
					<view class="text" style="color: rgba(0, 0, 0, 0.7);">{{ item.text }}</view>
					<view class="des">{{ item.des }}</view>
				</view>
			</view>

			<view class="vip_card">
				<view class="vip_box" :style="`background:` +isBgColor" v-if="!iosIsPay">
					<view class="left">
						<view class="line1">影视通VIP</view>
						<view class="line2">开通VIP会员 专享剧集立即免费</view>
					</view>
					<view class="right">
						<u-button style="color: rgba(135, 141, 255, 1);" text="我的会员" v-if="userInfoStore.is_vip == 1"
							:customStyle="buttonStyle" @click="openVip" />
						<u-button style="color: rgba(135, 141, 255, 1);" text="立即开通" v-else :customStyle="buttonStyle"
							@click="openVip" />
					</view>
				</view>
				<view class="vip_box" :style="`background:` +isBgColor" v-else>
					<view class="left">
						<view class="line1">影视通VIP</view>
						<view class="line2"> 开通VIP会员 专享剧集立即免费</view>
					</view>
					<view class="right">
						<u-button style="color: rgba(135, 141, 255, 1);" text="立即开通" :customStyle="buttonStyle"
							@click="openVip" />
					</view>
				</view>
			</view>

			<view class="menu_box" style="	padding:0 20rpx;background: #fff;">
				<view style="font-size: font-size: 32rpx;color: rgba(55, 57, 72, 1);padding: 20rpx 0 10rpx 20rpx;">
					全部功能
				</view>
				<view style="display: flex; flex-wrap: wrap;padding:0 20rpx;">
					<view class="item" style="flex: 0 0 24%;  margin-left: calc(4% / 4);  "
						v-for="(item, index) in menuListTwo" :key="item.id"
						@click="menuItemClick(item.rid, item.text, item.path,item.src)">
						<view class="left" v-if="userInfoStore.mgg == 1 "
							style="flex-direction: column;justify-content: center;align-items: center;">
							<view class="icon" v-if="item.id!= 8"
								style="width: 36rpx;height: 38rpx;margin-bottom: 16rpx;">
								<image class="image" :src="item.img" :style="{ width: item.width }" mode="widthFix">
								</image>
							</view>
							<view v-if="item.id!= 8" class="text" style="margin-left: 0;color: rgba(70, 74, 87, 1);">
								{{ item.text == '获取积分' ? '获取'+richtext.jfname :item.text }}</view>
						</view>
						<view class="left" v-else
							style="flex-direction: column;justify-content: center;align-items: center;">
							<view class="icon" style="width: 36rpx;height: 38rpx;margin-bottom: 16rpx;">
								<image class="image" :src="item.img" :style="{ width: item.width }" mode="widthFix">
								</image>
							</view>
							<view class="text" style="margin-left: 0;color: rgba(70, 74, 87, 1);">{{ item.text }}</view>
						</view>

					</view>
				</view>

			</view>
			<view class="vip_card" @click="jumpView('/pages/user/share/poster')">
				<view class="vip_box"
					style="padding: 20rpx 32rpx;background: linear-gradient(90deg, rgba(124, 124, 255, 1) 0%, rgba(181, 209, 255, 1) 100%);justify-content: start;">
					<view
						style="width: 112rpx;height: 112rpx;background: rgba(0, 0, 0, 0.2);border-radius: 16rpx;margin-right: 32rpx; display: flex;align-items: center;justify-content: center;">
						<image src="https://normalimg.wei.do/video_short/images/yqyl.png"
							style="width: 40rpx;height: 40rpx;" mode=""></image>
					</view>
					<view class="left">
						<view class="line2" style="display: flex;justify-content: space-between;align-items: center;">
							<view>邀请有礼</view>
							<view><u-icon name="arrow-right" color="#fff" size="12" :bold="true"></u-icon></view>
						</view>
						<view class="line2">所有通过您注册的用户，都将会给您带来收益</view>
					</view>

				</view>

			</view>
			<view class="copyright" v-if="copyrightData.length" @click="debugClick">
				<view class="item" v-for="(item, index) in copyrightData" :key="index">
					<image class="image" v-if="item.image" :src="item.image" mode="widthFix"></image>
					<!-- #ifdef MP-WEIXIN -->
					<text class="text">{{ item.name }}</text>
					<!-- #endif -->
					<!-- #ifdef H5 -->
					<a v-if="item.url" :href="item.url" target="_blank" rel="">
						<text class="text">{{ item.name }}</text>
					</a>
					<text v-else class="text">{{ item.name }}</text>
					<!-- #endif -->
				</view>
			</view>
			<view class="alert_box"
				v-if="platform != 'H5' && token && userInfoStore && configStore.system.mobile_switch == 1">
				<view class="item" v-if="!userInfoStore.verification.mobile">
					<text class="text">您还没有绑定手机号</text>
					<text class="btn" @click="alertBindButton('mobile')">去绑定</text>
				</view>
			</view>
			<u-modal :show="cdkey.show" :title="cdkey.title" :showCancelButton="true" @confirm="cdkeyConfirm"
				@cancel="cdkey.show = false">
				<view style="width: 100%;">
					<u-input v-model="cdkey.value" :customStyle="inputStyle" clearable placeholder="请输入兑换码"
						@change="inputChange" @blur="inputChange"></u-input>
				</view>
			</u-modal>
		</view>
		<view class="main_content" v-if="isStatus == 1">
			<view class="userinfo_box" v-if="userInfoStore" @click="jumpView('/pages/user/info/index')">
				<view class="avatar" style="margin-bottom: 16rpx;">
					<image class="image" :src="avatar" mode="aspectFill"></image>
				</view>
				<view class="info" :style="isStatus == 0?'margin-left :0':''">
					<view class="nickname">
						<text class="text">{{ userInfoStore.nickname }}</text>
						<image class="image" v-if="userInfoStore.is_vip == 1"
							src="https://normalimg.wei.do/video_short/icons/vip.png" mode="widthFix" @click="openVip">
						</image>
					</view>

					<view class="msg">
						<text class="text" style="color: #4a4a4a; opacity: 0.4;">
						  {{userInfoStore.vip_expiretime_text?'vip到期时间:'+userInfoStore.vip_expiretime_text:"你还不是VIP会员"}}
						</text>
<!-- 						<text class="text">用户ID：{{ userInfoStore.user_id }}</text> -->
						<!-- <text class="copy" @click.stop="copyText(userInfoStore.user_id)">复制</text> -->

					</view>

				</view>
				<!-- <image class="arrow" src="/static/icons/arrow.png" mode="widthFix"></image> -->
			</view>
			<view class="userinfo_box" v-else @click="jumpView('/pages/login/login')">
				<view class="avatar">
					<image class="image" src="https://normalimg.wei.do/video_short/images/avatar.png" mode="aspectFill">
					</image>
				</view>
				<view class="info">
					<view class="nickname">
						<text class="text">立即登录</text>
					</view>
					<view class="msg">
						<text class="text" style="color: #4a4a4a; opacity: 0.4;">
							登录后自动同步账号信息
						</text>
					</view>
				</view>
			</view>
			<!-- <view style="font-size: 20rpx;color: #333;margin-left:20rpx">
				{{userInfoStore.vip_expiretime_text?'vip到期时间:'+userInfoStore.vip_expiretime_text:"你还不是VIP会员"}}
			</view> -->
			<view class="vip_card">
				<!--  -->
				<view class="vip_box" v-if="iosIsPay">
					<view class="left">
						<view class="line1">开通会员尊享多项特权</view>
						<view class="line2">开通VIP会员 专享剧集立即免费</view>
					</view>
					<view class="right">
						<u-button text="我的会员" v-if="userInfoStore.is_vip == 1" :customStyle="buttonStyle"
							@click="openVip" />
						<u-button text="立即开通" v-else :customStyle="buttonStyle" @click="openVip" />
					</view>
				</view>
				<view class="vip_box" v-else>
					<view class="left">
						<view class="line1">开通会员尊享多项特权</view>
						<view class="line2">开通VIP会员 专享剧集立即免费</view>
					</view>
					<view class="right">
						<u-button text="联系我们" :customStyle="buttonStyle" @click="openVip" />
					</view>
				</view>
				<!-- <view class="integral_box" @click=" goMai();jumpView('/pages/user/integral/index')">
					<view class="right">
						<text class="text">我的{{richtext.jfname}}</text>
						<image class="image" src="https://normalimg.wei.do/video_short/icons/integral.png"
							mode="widthFix"></image>
						<text class="text">{{ userInfoStore.usable || 0 }}</text>
					</view>
					<view v-if="iosIsPay" class="left">去充值 ></view>
				</view> -->
			</view>

			<view class="card_box">
				<view class="item" v-for="(item, index) in cardList" :key="item.id" @click="cardItemClick(item)">
					<!-- <view class="icon">
						<image class="image" :src="item.img" mode="aspectFill"></image>
					</view> -->
					<view class="text">{{ item.text }}</view>
					<view class="des">{{ item.des }}</view>
				</view>
			</view>
			<view class="more-menu" style="padding: 32rpx;">
				<u--text text="更多功能" :size="18" :bold="true"></u--text>
				<u-cell-group :border="false">
					<u-cell icon="" title="修改密码" :isLink="true">
						<view class="" slot="icon" style="padding-top: 12rpx;">
							<u-icon size="32" name="/static/images/user-change-pwd.png"></u-icon>
						</view>
					</u-cell>
					<u-cell icon="" title="退出登录" :border="false" :isLink="true">
						<view class="" slot="icon" style="padding-top: 12rpx;">
							<u-icon size="32" name="/static/images/user-loginout.png"></u-icon>
						</view>
					</u-cell>
				</u-cell-group>
			</view>
			<!-- -->
			<!-- <view class="menu_box" v-if="userInfoStore.mgg == 1 || !mggStatus  ">
				<view v-if="item.id!=8" class="item" v-for="(item, index) in menuList" :key="item.id"
					@click="menuItemClick(item.rid, item.text, item.path,item.src)">
					<view class="left">
						<view class="icon">
							<image class="image" :src="item.img" :style="{ width: item.width }" mode="widthFix"></image>
						</view>
						<view class="text">{{ item.text == '获取积分' ? '获取'+richtext.jfname :item.text }}</view>
					</view>
					<view class="right">
						<u-icon name="arrow-right" color="#fff" size="12" :bold="true"></u-icon>
					</view>
				</view>
			</view>
			<view class="menu_box" v-else>
				<view class="item" v-for="(item, index) in menuList" :key="item.id"
					@click="menuItemClick(item.rid, item.text, item.path,item.src)">
					<view class="left">
						<view class="icon">
							<image class="image" :src="item.img" :style="{ width: item.width }" mode="widthFix"></image>
						</view>
						<view class="text">{{ item.text == '获取积分' ? '获取'+richtext.jfname :item.text }}</view>
					</view>
					<view class="right">
						<u-icon name="arrow-right" color="#fff" size="12" :bold="true"></u-icon>
					</view>
				</view>
			</view> -->

			<view class="alert_box"
				v-if="platform != 'H5' && token && userInfoStore && configStore.system.mobile_switch == 1">
				<view class="item" v-if="!userInfoStore.verification.mobile">
					<text class="text">您还没有绑定手机号</text>
					<text class="btn" @click="alertBindButton('mobile')">去绑定</text>
				</view>
			</view>
			<u-modal :show="cdkey.show" :title="cdkey.title" :showCancelButton="true" @confirm="cdkeyConfirm"
				@cancel="cdkey.show = false">
				<view style="width: 100%;">
					<u-input v-model="cdkey.value" :customStyle="inputStyle" clearable placeholder="请输入兑换码"
						@change="inputChange" @blur="inputChange"></u-input>
				</view>
			</u-modal>
		</view>


		<!-- <tabBar v-if="tabChange" selectedIndex =3></tabBar> -->
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutations,
		mapActions
	} from "vuex"
	export default {
		data() {
			return {
				avatar: "",
				isBgColor: getApp().globalData.isBgColor,
				isStatus: getApp().globalData.status,
				buttonStyle: {
					width: '100%',
					height: '100%',
					border: 'none',
					fontSize: '24rpx',
					color: getApp().globalData.isColor,
					background: '#fff',
					borderRadius: '32rpx',
					fontWeight: 'bold'
				},
				cardListTwo: [{
						id: 1,
						img: 'https://normalimg.wei.do/video_short/images/watched.png',
						text: '最近观看',
						path: '/pages/video/record'
					},
					// {
					// 	id: 4,
					// 	img: 'https://normalimg.wei.do/video_short/images/drama.png',
					// 	text: '卡密兑换',
					// 	path: ''
					// },
					// {
					// 	id: 3,
					// 	img: 'https://normalimg.wei.do/video_short/images/money.png',
					// 	text: '分享赚钱',
					// 	path: '/pages/user/share/index'
					// },
					// {
					// 	id: 2,
					// 	img: 'https://normalimg.wei.do/video_short/images/distributor.png',
					// 	text: '申请经销商',
					// 	path: '/pages/user/dealer/index'
					// },
					{
						id: 5,
						img: 'https://normalimg.wei.do/video_short/icons/menu_1.png',
						text: '在线客服',
						path: ''
					},
				],
				cardList: [{
						id: 1,
						img: 'https://normalimg.wei.do/video_short/icons/menu_2.png',
						text: '购买记录',
						path: '/pages/video/record',
						des: '记录账单详情',
					},
					// {
					// 	id: 2,
					// 	img: 'https://normalimg.wei.do/video_short/icons/menu_3.png',
					// 	text: '申请分销商',
					// 	path: '/pages/user/dealer/index'
					// },
					// {
					// 	id: 3,
					// 	img: 'https://normalimg.wei.do/video_short/icons/menu_4.png',
					// 	text: '分享赚钱',
					// 	path: '/pages/user/share/index'
					// },
					// {
					// 	id: 4,
					// 	img: 'https://normalimg.wei.do/video_short/icons/menu_1.png',
					// 	text: '卡密兑换',
					// 	path: ''
					// },
					{
						id: 5,
						img: 'https://normalimg.wei.do/video_short/icons/menu_1.png',
						text: '在线客服',
						path: '',
						des: '24小时在线服务',
					},
				],
				menuListTwo: [

					{
						id: 2,
						img: 'https://normalimg.wei.do/video_short/images/Agreement.png',
						width: '32rpx',
						text: '用户协议',
						rid: ''
					},

					{
						id: 5,
						img: 'https://normalimg.wei.do/video_short/images/Contact.png',
						width: '28rpx',
						text: '联系我们',
						rid: ''
					},
					{
						id: 1,
						img: 'https://normalimg.wei.do/video_short/images/yqhy.png',
						width: '32rpx',
						text: '邀请好友',
						rid: '',
						path: '/pages/user/share/poster'
					},
					// { id: 1, img: '/static/images/yqhy.png', width: '32rpx', text: '邀请好友', rid: '', path: '/pages/user/share/poster' },
					// #ifdef MP-WEIXIN
					{
						id: 8,
						img: ' https://normalimg.wei.do/video_short/icons/list_2.png',
						width: '28rpx',
						text: '免广告',
						rid: ''
					},
					// #endif
					{
						id: 6,
						img: 'https://normalimg.wei.do/video_short/images/About.png',
						width: '28rpx',
						text: '关于我们',
						rid: ''
					},
					{
						id: 7,
						img: 'https://normalimg.wei.do/video_short/images/points.png',
						width: '28rpx',
						text: '获取积分',
						rid: '',
						path: '/pages/user/integral/task'
					},
					{
						id: 4,
						img: 'https://normalimg.wei.do/video_short/images/Notice.png',
						width: '32rpx',
						text: '法律声明',
						rid: ''
					},
					{
						id: 3,
						img: 'https://normalimg.wei.do/video_short/images/Privacy.png',
						width: '28rpx',
						text: '隐私协议',
						rid: ''
					},
				],
				menuList: [
					// #ifndef APP-PLUS
					{
						id: 1,
						img: 'https://normalimg.wei.do/video_short/images/yqhyOr.png',
						width: '32rpx',
						text: '邀请好友',
						rid: '',
						path: '/pages/user/share/poster'
					},
					// #endif
					{
						id: 7,
						img: 'https://normalimg.wei.do/video_short/icons/list_2.png',
						width: '28rpx',
						text: '获取积分',
						rid: '',
						path: '/pages/user/integral/task'
					},
					// #ifdef MP-WEIXIN
					{
						id: 8,
						img: 'https://normalimg.wei.do/video_short/icons/list_2.png',
						width: '28rpx',
						text: '免广告',
						rid: ''
					},
					// #endif
					{
						id: 2,
						img: 'https://normalimg.wei.do/video_short/icons/list_4.png',
						width: '28rpx',
						text: '用户协议',
						rid: ''
					},
					{
						id: 3,
						img: 'https://normalimg.wei.do/video_short/icons/list_2.png',
						width: '28rpx',
						text: '隐私协议',
						rid: ''
					},
					{
						id: 4,
						img: 'https://normalimg.wei.do/video_short/icons/list_3.png',
						width: '28rpx',
						text: '法律声明',
						rid: ''
					},
					{
						id: 5,
						img: 'https://normalimg.wei.do/video_short/icons/list_5.png',
						width: '32rpx',
						text: '联系我们',
						rid: ''
					},
					{
						id: 6,
						img: 'https://normalimg.wei.do/video_short/icons/list_3.png',
						width: '28rpx',
						text: '关于我们',
						rid: ''
					},
					{
						id: 7,
						img: 'https://normalimg.wei.do/video_short/icons/list_3.png',
						width: '28rpx',
						text: '在线客服',
						rid: '',
						src: 'https://zaixiankefu.com'
					},
				],
				copyrightData: this.$store.state.app.copyright || [], // 版权说明
				platform: this.$utils.platforms(),
				configStore: this.$store.state.app.config,
				userInfoStore: this.$store.state.user.userInfo,
				debug: {
					count: 0,
					timer: null
				},
				cdkey: {
					show: false,
					title: '卡密兑换',
					value: '',
				},
				inputStyle: {},
				//tab更新
				tabChange: false,
				//免广告支付判断
				buttonLoading: false,
				//免广告支付所需超参数
				dredge: { // 需要开通的参数
					mgg_id: '',
					total_fee: ''
				},
				mggStatus: "",
			}
		},
		computed: {
			...mapGetters("user", ["token", "userInfo"]),
			...mapGetters("app", ["config", "copyright", "richtext", "iosIsPay"]),
		},
		watch: {
			config: {
				deep: true,
				handler: function(newValue, oldValue) {
					this.configStore = newValue
				}
			},
			userInfo: {
				deep: true,
				handler: function(newValue, oldValue) {
					this.userInfoStore = newValue
				}
			},
			copyright(newValue, oldValue) {
				this.copyrightData = newValue
			},
			richtext(newValue, oldValue) {
				newValue && this.initMenuList(newValue)
			}
		},
		onTabItemTap() {
			this.$request('common.point', {
				item_id: 4,
				platform: this.$utils.platforms(),
				point_type: 5
			}, false).then(res => {

			})
		},
		onPullDownRefresh() {
			if (this.token) {
				this.getUserInfo().then(res => {
					uni.stopPullDownRefresh()
				}).catch(err => {
					uni.stopPullDownRefresh()
				})
			} else {
				uni.stopPullDownRefresh()
			}
		},
		onLoad() {
			uni.$on('updateUserInfo', () => {
				this.getUserInfo()
			})
			////console.log("用户信息", this.userInfo.avatar)
			let tt = ""
			let avatar = this.userInfo.avatar

			uni.getStorage({
				key: 'commonUrl',
				success: function(res) {
					tt = res.data.resourceUrl + avatar + '.txt'
				}
			});
			////console.log("头像地址请求", tt)
			uni.request({
				url: tt,
				success: (res) => {
					////console.log("请求道德", res)
					////console.log("请求道德+!", this.avatar)
					this.avatar = res.data
					////console.log("请求道德++++!", this.avatar)
				},
				fail: (err) => {
					////console.log("头像请求失败", err)
				}
			})
			////console.log("头像", this.avatar)
			this.mggTrue()
			this.dealerLevelList()
			this.richtext && this.initMenuList(this.richtext)
		},
		onShow() {
			this.tabChange = true

			this.token && this.getUserInfo()
		},
		onHide() {
			this.tabChange = false
		},
		onUnload() {
			uni.$off('updateUserInfo')

		},
		methods: {
			...mapActions('user', ['getUserInfo', 'userinfo']),
			goMai() {
				this.$request('common.point', {
					platform: this.$utils.platforms(),
					point_type: 7
				}, false).then(res => {

				})
			},
			mggTrue() {

				this.$request('mgg.mggswitch', '', false).then(res => {
					if (res.code === 1) {
						////console.log(res)
						this.mggStatus = res.data.switch

					}
				})
			},
			// 调试
			debugClick() {
				// #ifdef MP-WEIXIN
				const env = wx.getAccountInfoSync().miniProgram.envVersion
				if (env != "release") {
					clearTimeout(this.debug.timer);
					this.debug.count++;
					this.debug.timer = setTimeout(() => {
						if (this.debug.count >= 5) {
							uni.showModal({
								title: '配置信息',
								content: `
									(env => ${env}) -
									(domain => ${this.$BASE_URL}) -
									(sign => ${this.$SIGN})
								`
							})
						}
						this.debug.count = 0;
					}, 500);
				}
				// #endif
			},
			alertBindButton(type) {
				if (type == 'wxmp') {
					////console.log("绑定微信小程序");
				} else if (type == 'wxoa') {
					////console.log("绑定微信公众号");
				} else if (type == 'mobile') {
					////console.log("绑定手机号");
					this.jumpView('/pages/user/info/index')
				}
			},
			// 复制
			// copyText(info) {
			// 	uni.setClipboardData({
			// 		data: String(info),
			// 		success: () => {
			// 			this.$u.toast('复制成功')
			// 		}
			// 	});
			// },
			// 富文本ID
			initMenuList(data) {
				if (this.isStatus == 0) {
					////console.log('进入蓝色')

					this.menuListTwo.map(item => {
						switch (item.id) {
							case 2:
								item.rid = data.user_protocol
								break;
							case 3:
								item.rid = data.privacy_protocol
								break;
							case 4:
								item.rid = data.legal_notice
								break;
							case 5:
								item.rid = data.contact_us
								break;
							case 6:
								item.rid = data.about_us
								break;
							case 8:
								item.rid = 100
								break;
						}
					})
				} else {
					////console.log('进入橙色')

					this.menuList.map(item => {
						switch (item.id) {
							case 2:
								item.rid = data.user_protocol
								break;
							case 3:
								item.rid = data.privacy_protocol
								break;
							case 4:
								item.rid = data.legal_notice
								break;
							case 5:
								item.rid = data.contact_us
								break;
							case 6:
								item.rid = data.about_us
								break;
							case 8:
								item.rid = 100
								break;
						}
					})
				}

			},
			// 菜单列表点击
			menuItemClick(id, title, url, src) {

				if (url) {
					if (!this.token) return this.$u.toast('请先登录!')
					this.jumpView(url)
				} else {
					////console.log(id, '这是id')
					// if(!id) return this.$u.toast('功能正在开发中')
					if (src) {
					return	window.location.href = src
					
					}

					if (id == 100) {
						// #ifdef MP-WEIXIN
						if (!this.iosIsPay) return this.jumpView('/pages/user/info/contact')
						// #endif
						uni.showModal({
							title: '开通免广告权限',
							content: `开通免广告所需费用${this.dredge.total_fee}元`,
							success: res => {
								if (res.confirm) {
									////console.log('用户点击确定');
									this.dredgeDealer()

								} else if (res.cancel) {
									////console.log('用户点击取消');
								}
							}
						})


					} else {
						if (!id) return this.$u.toast('请先在后台-剧场管理-系统配置-协议配置中编辑协议，然后在剧场配置-基础配置中选择各个协议对应所编辑的协议')
						const obj = {
							id,
							title
						}
						this.jumpView(`/pages/user/info/richtext?d=${encodeURIComponent(JSON.stringify(obj))}`)
					}

				}
			},
			// 会员中心
			openVip() {
				// #ifdef MP-WEIXIN
				if (!this.iosIsPay) return this.jumpView('/pages/user/info/contact')
				// #endif

				if (!this.token) {
					this.$u.toast('请先登录!')
					setTimeout(() => {
						return this.jumpView('/pages/login/login')
					}, 2000)
				} else {
					this.$request('common.point', {
						platform: this.$utils.platforms(),
						point_type: 6
					}, false).then(res => {

					})
					this.jumpView('/pages/user/member/index')
				}

			},
			// 输入框验证
			inputChange() {
				let result = false
				if (!this.cdkey.value) {
					this.inputStyle = {
						borderColor: 'red !important'
					}
				} else {
					this.inputStyle = {}
					result = true
				}
				return result
			},
			// 卡密兑换
			cdkeyConfirm() {
				if (!this.inputChange()) return
				uni.showLoading({
					title: '兑换中'
				})

				this.$request('user.cdkey', {
					crypto: this.cdkey.value,
					platform: this.$utils.platforms()
				}).then(res => {
					if (res.code === 1) {
						this.getUserInfo()
						this.$u.toast(res.msg)
					}
					this.cdkey.value = ''
					this.cdkey.show = false
					// uni.hideLoading()
				}).catch(err => {
					this.$u.toast('兑换失败')
					this.cdkey.value = ''
					this.cdkey.show = false
					uni.hideLoading()
				})
			},
			// 功能区点击
			cardItemClick(item) {
				if (!item.path) {
					if (item.id === 4) {
						if (!this.token) return this.$u.toast('请先登录!')
						this.cdkey.show = true
					} else {
						this.$u.toast('暂未开放')
					}
				} else {
					if (item.id === 2) {
						// #ifdef MP-WEIXIN
						if (!this.iosIsPay) return this.jumpView('/pages/user/info/contact')
						// #endif
					}
					if (!this.token) return this.$u.toast('请先登录!')
					this.jumpView(item.path)
				}
			},
			//免广告支付
			dealerLevelList() {
				this.$request('mgg.level', '', false).then(res => {
					if (res.code === 1 && res.data.length > 0) {
						let item = res.data.list.filter(item => item.level == this.dredgeLevel)[0]
						this.dredge.mgg_id = res.data.list[0].id
						this.dredge.total_fee = res.data.list[0].price

					}
				})
			},
			dredgeDealer() {
				// #ifdef MP-WEIXIN
				if (!this.iosIsPay) return this.jumpView('/pages/user/info/contact')
				// #endif

				const buy = () => {
					this.buttonLoading = true
					uni.showLoading({
						title: '开通中...',
						mask: true
					})
					// #ifdef MP-TOUTIAO

					this.$request('mgg.createOrder', {
						...this.dredge,
						platform: 'douyinxcx'
					}).then(res => {
						if (res.code === 1) {
							this.callPay(res.data.order_sn, 'douyinxcx', res.data.platform)

						} else {
							this.buttonLoading = false
							uni.hideLoading()
						}
					}).catch(err => {
						this.buttonLoading = false
						uni.hideLoading()
					})
					// #endif
					// #ifndef MP-TOUTIAO
					this.$request('mgg.createOrder', {
						...this.dredge,
						platform: this.$utils.platforms()
					}).then(res => {
						if (res.code === 1) {


							this.callPay(res.data.order_sn, 'wechat', res.data.platform)

						} else {
							this.buttonLoading = false
							uni.hideLoading()
						}
					}).catch(err => {
						this.buttonLoading = false
						uni.hideLoading()
					})
					// #endif
				}


				buy()
			},
			//虚拟支付调起
			xGetPay(order_sn, payment, platform) {
				uni.login({
					provider: 'weixin',
					success: success => {
						if (success.errMsg === 'login:ok') {

							this.$request('common.xunipay', {
								order_sn,
								payment,
								platform,
								code: success.code
							}).then(res => {
								////console.log(res)
								if (res.code === 1) {
									if (platform == 'H5') {
										const div = document.createElement('divpay');
										div.innerHTML = res.data.pay_data;
										document.body.appendChild(div);
									} else {
										this.xunipay(res.data.pay_data)
									}
								}
							})

						}
					}
				})
			},
			//非虚拟支付调起
			getPay(order_sn, payment, platform) {
				this.$request('common.pay', {
					order_sn,
					payment,
					platform,
				}).then(res => {
					////console.log(res)
					if (res.code === 1) {
						if (platform == 'H5') {
							const div = document.createElement('divpay');
							div.innerHTML = res.data.pay_data;
							document.body.appendChild(div);
						} else {
							this.pay(res.data.pay_data)
						}
					}
				})
			},
			// 发起支付请求
			callPay(order_sn, payment, platform) {
				// #ifdef MP-TOUTIAO
				var that = this
				this.$request('common.dypay', {
					order_sn,
					payment,
					platform,
				}).then(res => {
					////console.log(res)
					if (res.code === 1) {

						if (platform == 'H5') {
							const div = document.createElement('divpay');
							div.innerHTML = res.data.pay_data;
							document.body.appendChild(div);
						} else {
							tt.pay({
								orderInfo: {
									order_id: res.data.pay_data.data.order_id,
									order_token: res.data.pay_data.data.order_token,
								},
								service: 5,
								success(res) {
									////console.log(res, 'success')
									if (res.code == 0) {
										uni.showToast({
											title: '支付成功',
											icon: 'none',
											duration: 2000
										});
										that.buttonLoading = false
										that.getPageData()
										uni.hideLoading()

										// 支付成功处理逻辑，只有res.code=0时，才表示支付成功
										// 但是最终状态要以商户后端结果为准
									} else {
										uni.showToast({
											title: '支付失败',
											icon: 'none',
											duration: 2000
										});
										that.buttonLoading = false
										uni.hideLoading()
									}
								},
								fail(res) {
									////console.log(res, 'fail')
									uni.showToast({
										title: '支付失败',
										icon: 'none',
										duration: 2000
									});
									that.buttonLoading = false
									uni.hideLoading()
									// 调起收银台失败处理逻辑
								},
							});
						}
					}
				})

				// #endif
				// #ifndef MP-TOUTIAO
				this.$request('common.ifxunipay').then(res => {

					if (res.data.xunipay_switch == 0) {
						this.getPay(order_sn, payment, platform)
					} else {
						// #ifdef MP-WEIXIN
						var iosd = wx.getSystemInfoSync()

						if (this.iosIsPay && iosd.platform == 'ios') {
							this.getPay(order_sn, payment, platform)

						} else {

							this.xGetPay(order_sn, payment, platform)
						}
						// #endif
						// #ifndef MP-WEIXIN
						this.getPay(order_sn, payment, platform)
						// #endif

					}
				})
				// #endif


			},
			// 发起 小程序/公众号 支付
			xunipay(pay) {
				var that = this
				// #ifdef MP-WEIXIN
				const SDKVersion = wx.getSystemInfoSync().SDKVersion

				if (that.compareVersion(SDKVersion, '2.19.2') >= 0 || wx.canIUse('requestVirtualPayment')) {
					wx.requestVirtualPayment({
						signData: JSON.stringify({
							offerId: pay.signData.offerId,
							buyQuantity: pay.signData.buyQuantity,
							env: pay.signData.env,
							currencyType: pay.signData.currencyType,
							platform: pay.signData.platform,
							productId: pay.signData.productId,
							goodsPrice: pay.signData.goodsPrice,
							outTradeNo: pay.signData.outTradeNo,
							attach: pay.signData.attach,
						}),
						paySig: pay.paySig,
						signature: pay.signature,
						mode: pay.mode,
						success(res) {
							//////console.log('requestVirtualPayment success', res)
							uni.showToast({
								title: '支付成功',
								icon: 'none',
								duration: 2000
							});
							that.buttonLoading = false
							that.getPageData()
							uni.hideLoading()


						},
						fail({
							errMsg,
							errCode
						}) {
							//////console.error(errMsg, errCode)
							uni.showToast({
								title: errMsg,
								icon: 'none',
								duration: 2000
							});
							that.buttonLoading = false
							uni.hideLoading()
						},
					})
				} else {
					//////console.log('当前用户的客户端版本不支持 wx.requestVirtualPayment')

					uni.showToast({
						title: '当前用户的客户端版本不支持小程序虚拟支付',
						icon: 'none',
						duration: 2000
					});
					that.buttonLoading = false
					uni.hideLoading()

				}
				// #endif

			},
			pay(pay) {
				var that = this
				// #ifdef MP-WEIXIN
				uni.requestPayment({
					timeStamp: pay.timeStamp,
					nonceStr: pay.nonceStr,
					package: pay.package,
					signType: pay.signType,
					paySign: pay.paySign,
					success: success => {
						uni.showToast({
							title: '支付成功',
							icon: 'none',
							duration: 2000
						});
						that.buttonLoading = false
						that.getPageData()
						uni.hideLoading()
					},
					fail: fail => {
						uni.showToast({
							title: '支付失败',
							icon: 'none',
							duration: 2000
						});
						that.buttonLoading = false
						uni.hideLoading()
					}
				})
				// #endif

				// #ifdef H5
				WeixinJSBridge.invoke(
					'getBrandWCPayRequest', {
						"appId": pay.appId, // 公众号ID，由商户传入     
						"timeStamp": pay.timeStamp, // 时间戳，自1970年以来的秒数     
						"nonceStr": pay.nonceStr, // 随机串     
						"package": pay.package, // 订单详情扩展字符串
						"signType": pay.signType, // 微信签名方式：     
						"paySign": pay.paySign // 微信签名 
					},
					res => {
						if (res.err_msg == "get_brand_wcpay_request:ok") {
							uni.showToast({
								title: '支付成功',
								icon: 'none',
								duration: 2000
							});
							that.buttonLoading = false
							that.getPageData()
							uni.hideLoading()
						} else {
							uni.showToast({
								title: '支付失败',
								icon: 'none',
								duration: 2000
							});
							that.buttonLoading = false
							uni.hideLoading()
						}
					});
				// #endif
				// #ifdef APP-PLUS
				// APP
				uni.getProvider({
					service: "payment",
					success: e => {
						const type = e.provider.includes('wxpay')
						type && uni.requestPayment({
							"provider": "wxpay",
							"orderInfo": pay,
							success: success => {
								uni.showToast({
									title: '支付成功',
									icon: 'none',
									duration: 2000
								});
								that.buttonLoading = false
								that.getPageData()
								uni.hideLoading()

							},
							fail: fail => {
								if (fail.errCode === -8) {
									uni.showToast({
										title: '未安装微信客户端',
										icon: 'none',
										duration: 2000
									});
									that.buttonLoading = false
									uni.hideLoading()
								} else {
									uni.showToast({
										title: '支付失败',
										icon: 'none',
										duration: 2000
									});
									that.buttonLoading = false
									uni.hideLoading()
								}
							}
						})
					},
					fail: e => {
						that.payFail("获取iap支付通道失败")
					}
				});
				// #endif


			},
			//个人信息处理
			getPageData() {
				this.getUserInfo().then(res => {
					if (res.code === 1) {
						// this.userInfo = { avatar: res.data.avatar }
						////console.log("个人信息", res.data)
						this.userInfo = res.data

					}
				})
			},
			//判断微信js版本用
			compareVersion(_v1, _v2) {
				if (typeof _v1 !== 'string' || typeof _v2 !== 'string') return 0

				const v1 = _v1.split('.')
				const v2 = _v2.split('.')
				const len = Math.max(v1.length, v2.length)

				while (v1.length < len) {
					v1.push('0')
				}
				while (v2.length < len) {
					v2.push('0')
				}

				for (let i = 0; i < len; i++) {
					const num1 = parseInt(v1[i], 10)
					const num2 = parseInt(v2[i], 10)

					if (num1 > num2) {
						return 1
					} else if (num1 < num2) {
						return -1
					}
				}

				return 0
			},

		}
	}
</script>

<style lang="scss" scoped>
	.page_content {
		position: relative;

		.head_content {}

		.main_content {
			// padding: 24rpx 40rpx 152rpx 40rpx;
			overflow-y: auto;

			.userinfo_box {
				margin: 0 32rpx;
				display: flex;
				align-items: center;
				position: relative;

				.arrow {
					position: absolute;
					top: 50%;
					right: 0;
					transform: translateY(-50%) rotate(0deg);
					width: 44rpx;
				}

				.avatar {
					width: 130rpx;
					height: 130rpx;
					border-radius: 50%;
					border: 2rpx solid #fff;
					overflow: hidden;

					.image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.info {
					flex: 1;
					margin-left: 32rpx;

					.nickname {
						display: flex;

						.text {
							font-size: 34rpx;
							color: #000;
							font-weight: 900;
						}

						.image {
							width: 52rpx;
							margin-left: 8rpx;
						}
					}

					.msg {
						margin-top: 20rpx;
						font-size: 24rpx;

						.text {
							color: #808080;
						}

						.copy {
							color: #5E5E5E;
							margin-left: 8rpx;
							text-decoration: underline;
							display: inline-block;
						}
					}
				}
			}

			.vip_card {
				border-radius: 16rpx 16rpx 0 0;
				overflow: hidden;
				margin: 40rpx 32rpx 0 32rpx;
				background: linear-gradient(90deg, #7E7BFF 0%, #B4C0FB 100%);

				.vip_box {
					width: 100%;
					min-height: 144rpx;
					padding: 0 32rpx;
					box-sizing: border-box;
					// background: #DF9B45;
					// background-image: url('https://normalimg.wei.do/video_short/images/vip_bg.png');
					background-image: url('~@/static/images/user-vip-bg.png');
					background-size: 100% 100%;
					background-repeat: no-repeat;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.left {
						color: #fff;

						.line1 {
							font-size: 32rpx;
							font-weight: bold;
						}

						.line2 {
							font-size: 24rpx;
							margin-top: 16rpx;
							opacity: 0.5;
						}
					}

					.right {
						width: 156rpx;
						height: 60rpx;
						/deep/ .u-button__text {
							background: linear-gradient(90deg, #7E7BFF 0%, #B4C0FB 100%);
							-webkit-background-clip: text;
							  background-clip: text;
							  color: transparent;
						}
					}
				}

				// .integral_box {
				// 	height: 80rpx;
				// 	// background: #DE9E45;
				// 	display: flex;
				// 	align-items: center;
				// 	justify-content: space-between;
				// 	color: #fff;
				// 	padding: 0 32rpx;
				// 	font-size: 24rpx;
				// 	font-weight: 700;

				// 	.left {
				// 		color: #fff;
				// 	}

				// 	.right {
				// 		display: flex;
				// 		align-items: center;

				// 		.image {
				// 			width: 30rpx;
				// 			margin-right: 8rpx;
				// 			margin-left: 12rpx;
				// 		}

				// 		.text {}
				// 	}
				// }
			}

			.card_box {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				// flex-wrap: wrap;
				background: #fff;
				border-radius: 40rpx;
				padding: 32rpx;
				// background: linear-gradient(141.96deg, #EE7F33 0%, #FFB98A 100%);

				.item {
					background: #ddeeff;
					border-radius: 32rpx;
					width: 50%;
					margin-right: 14rpx;
					background-image: url('~@/static/images/user-card-order-list.png');
					background-repeat: no-repeat;
					background-size: 100%;
					
					+.item {
						background: #fddce0;
						margin-right: 0;
						margin-left: 14rpx;
						background-image: url('~@/static/images/user-card-online.png');
						background-repeat: no-repeat;
						background-size: 100%;
						.text {
							background: linear-gradient(180deg, #E45D6A 0%, #FA7589 100%);
							-webkit-background-clip: text;
							background-clip: text;
							color: transparent;
						}
					}

					// .icon {
					// 	width: 84rpx;
					// 	height: 84rpx;
					// 	margin: 0 auto;

					// 	.image {
					// 		width: 100%;
					// 		height: 100%;
					// 	}
					// }

					.text {
						font-size: 32rpx;
						font-weight: 600;
						padding: 32rpx 32rpx 4rpx 32rpx;
						background: linear-gradient(180deg, #44A3F8 0%, #44A3F8 100%);
						-webkit-background-clip: text;
						background-clip: text;
						color: transparent;
					}
					.des {
						color: #4a4a4a;
						opacity: 0.5;
						padding: 4rpx 32rpx 32rpx 32rpx;
					}
				}
			}

			.menu_box {
				background: #fff;
				border-radius: 16rpx;
				padding: 30rpx 40rpx;
				margin-top: 40rpx;
				background: linear-gradient(141.96deg, #EE7F33 0%, #FFB98A 100%);

				.item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 28rpx 0;

					.left {
						display: flex;
						align-items: center;

						.icon {
							width: 36rpx;
							height: 36rpx;
							display: flex;
							align-items: center;
							justify-content: center;

							.image {
								width: 100%;
							}
						}

						.text {
							font-size: 28rpx;
							// color: #333;
							color: #fff;
							margin-left: 40rpx;
							font-weight: bold;
						}
					}

					.right {
						.image {
							width: 32rpx;
						}
					}
				}
			}

			.copyright {
				margin-top: 60rpx;

				.item {
					display: flex;
					align-items: center;
					justify-content: center;
					line-height: 36rpx;

					a {
						text-decoration: none;
					}

					.image {
						width: 30rpx;
						margin-right: 8rpx;
					}

					.text {
						font-size: 24rpx;
						color: rgba(#999, 0.5);
					}
				}
			}

			.alert_box {
				width: 100%;
				padding: 0 40rpx;
				position: absolute;
				bottom: 20rpx;
				left: 0;

				.item {
					padding: 20rpx;
					border-radius: 20rpx;
					background: rgba(0, 0, 0, 0.9);
					color: #fff;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.text {}

					.btn {
						background: #C78021;
						padding: 8rpx 20rpx;
						border-radius: 10rpx;
					}
				}
			}
		}
	}
</style>